package net.sourceforge.openclixml.ext;

import net.sourceforge.openclixml.EvaluationFailedException;
import net.sourceforge.openclixml.environment.IEnvironment;

import org.w3c.dom.Document;

import java.util.Iterator;
import java.util.Map;


/**
 *
 * @version $Revision: 39 $
 * @author dominikjungo
 *
 * Last changed: $Date: 2008-01-22 21:38:51 +0100 (Tue, 22 Jan 2008) $
 * The License for this file can be found in doc/Licenses/license-OpenCliXML.txt
 */
public class RulesType extends net.sourceforge.openclixml.autogen.RulesType {
    /**
     * Evaluates all children.
     *
     * {@inheritDoc}
     *
     */
    @Override
    public boolean evalDelegated(
        final IEnvironment<String, String> environment,
        final Map<String, Document> systemUnderTest)
        throws EvaluationFailedException {
        boolean result = true;

        Iterator<net.sourceforge.openclixml.autogen.RuleType> iter = getRule()
                                                                         .iterator();

        while (iter.hasNext()) {
            result &= iter.next().eval(environment, systemUnderTest);
        }

        setSuccess(result);

        return result;
    }
}
